#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main() {
    int n = 0;
    cin >> n;
    int flag = 2;
    vector<string> vstr(n);
    for (int i = 0; i < n; i++)
    {
        cin >> vstr[i];
    }
    for (int i = 0; i < n - 1; i++)
    {
        if (vstr[i].compare(vstr[i + 1]) > 0)
        {
            flag = -1;
            break;
        }
    }
    for (int i = 0; i < n - 1; i++)
    {
        if (vstr[i].length() > vstr[i + 1].length())
        {
            if (flag == -1)
            {
                flag = 0;
                break;
            }
            else
            {
                flag = 1;
                break;
            }


        }
    }
    if (flag == -1)
        cout << "lengths";
    else if (flag == 1)
        cout << "lexicographically";
    else if (flag == 0)
        cout << "none";
    else
        cout << "both";
}